<include file="Public/header" />
<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3>固件管理</h3>
      <ul class="tab-base">
        <li><a href="{:U('Firmware/firmware')}"><span>管理</span></a></li>
        <li><a href="JavaScript:void(0);" class="current"><span>新增</span></a></li>
      </ul>
    </div>
  </div>
  <div class="fixed-empty"></div> 
  <form id="goods_form" method="post" name="goods_form" enctype="multipart/form-data">
    <table class="table tb-type2 nobdb">
      <tbody>

      <tr class="noborder">
        <td colspan="2" class="required"><label class="validation">所属类别:</label></td>
      </tr>
      <tr class="noborder">
        <td width="46" class="vatop rowform">
          <select name="class" id="class">
            <option value="驱动包">驱动包</option>
            <option value="BIOS和EC">BIOS和EC</option>
            <option value="显示驱动程序">显示驱动程序</option>
            <option value="声卡驱动程序">声卡驱动程序</option>
            <option value="USB串行ATA驱动程序">USB串行ATA驱动程序</option>
            <option value="芯片组">芯片组</option>
            <option value="WiFi驱动程序">WiFi驱动程序</option>
            <option value="网络驱动程序">网络驱动程序</option>
            <option value="蓝牙驱动程序">蓝牙驱动程序</option>
            <option value="软件程序">软件程序</option>
            <option value="USB端口驱动">USB端口驱动</option>
            <option value="General Driver">General Driver</option>
            <option value="其它驱动程序">其它驱动程序</option>
            <option value="操作指南">操作指南</option>
            <option value="指纹驱动">指纹驱动</option>
            <option value="操作系统">操作系统</option>
            <option value="固件">固件</option>
          </select>
        </td>
        <td class="vatop tips"></td>
      </tr>


        <tr class="noborder">
          <td colspan="2" class="required"><label class="validation">所属版本:</label></td>
        </tr>
        <tr class="noborder">
          <td width="46" class="vatop rowform">
            <select name="ver" id="ver">
              <option value="cn">中文(cn)</option>
              <option value="en">英文(en)</option>
            </select>
          </td>
          <td class="vatop tips"></td>
        </tr>

        <tr class="noborder">
          <td colspan="2" class="required"><label class="validation">固件名称:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="" name="name" id="name" class="txt"></td>
          <td class="vatop tips"></td>
        </tr>

        <tr class="noborder">
          <td colspan="2" class="required"><label class="validation">固件描述:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><textarea id="describe" class="tarea" rows="3" name="describe"></textarea></td>
          <td class="vatop tips"></td>
        </tr>

        <!--<tr class="noborder">
          <td colspan="2" class="required"><label class="validation" for="gc_id">所属分类:</label></td>
        </tr>
        <tr class="noborder">
          <td width="46" class="vatop rowform"><select name="gc_id" id="gc_id">
              <option value="">请选择...</option>
 			  <volist name="class_list" id="v">	
              <option value="{$v['gc_id']}">{$v['gc_name']}</option>
			  </volist>
            </select></td>
          <td class="vatop tips"></td>
        </tr>      
        <tr class="noborder">
          <td colspan="2" class="required"><label class="validation">产品名称:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="" name="goods_name" id="goods_name" class="txt"></td>
          <td class="vatop tips"></td>
        </tr>-->

        <!--<tr class="noborder">
          <td colspan="2" class="required"><label class="validation">产品价格:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform">
          <input type="text" value="" name="goods_store_price" id="goods_store_price" class="txt">
          </td>
          <td class="vatop tips"></td>
        </tr>-->

        <!--<tr class="noborder">
          <td colspan="2" class="required"><label>产品规格:</label></td>
        </tr>
        <tr class="noborder">
          <td colspan="15">
            <table class="table tb-type2">
              <thead id="spec_tt">
                <tr class="noborder">
                  <th class="w48 sort">排序</th>
                  <th class="w270 name">规格值</th>
                  <th class="w270 price">价格</th>
                  <th class="w150 align-center">操作</th>
                  <th></th>
                </tr>
              </thead>
              <tbody id="tr_model">
				<tr></tr>
              </tbody>
              <tbody>
                <tr>
                  <td colspan="15"><a class="btn-add marginleft" id="add_type" href="JavaScript:void(0);" onclick="add_spec()"> <span>添加一个规格值</span> </a></td>
                </tr>
              </tbody>
            </table>        
          </td>
        </tr>-->
                    
<!--        <tr class="noborder">
          <td colspan="2" class="required"><label class="validation">产品库存:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="" name="goods_storage" id="goods_price" class="txt"></td>
          <td class="vatop tips"></td>
        </tr>
        <tr class="noborder">
          <td colspan="2" class="required"><label>产品货号:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="" name="goods_serial" id="goods_serial" class="txt"></td>
          <td class="vatop tips"></td>
        </tr>   -->     
                    
        <!--<tr class="noborder">
          <td colspan="2" class="required"><label class="validation">排序:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="10" name="goods_sort" id="goods_sort" class="txt"></td>
          <td class="vatop tips"></td>
        </tr>-->

        <tr class="noborder">
          <td colspan="2" class="required"><label>下载文件:</label></td>
        </tr>
        <!--<tr class="noborder">
         <td class="vatop rowform">  
            <span class="type-file-show">
          	&lt;!&ndash;<img class="show_image" src="__IMG__/preview.png">&ndash;&gt;
            <div class="type-file-preview"><img src="__UPLOADS__{$rs['download']}"></div>
            </span>
            <span class="type-file-box">
            <input type='text' name='txt_goods_pic' id='txt_goods_pic' class='type-file-text' />
            <input type='button' name='but_goods_pic' id='but_goods_pic' value='' class='type-file-button' />
            <input name="download" type="file" class="type-file-file" id="goods_pic" size="30" hidefocus="true" nc_type="change_goods_pic">
            </span>
          </td>
          <td class="vatop tips"><span class="vatop rowform"></span></td>
        </tr>-->

      <tr class="noborder">
        <td class="vatop rowform"><textarea id="download" class="tarea" rows="3" name="download"></textarea></td>
        <td class="vatop tips"></td>
      </tr>


      </tbody>
      <tfoot>
        <tr class="tfoot">
          <td colspan="20" ><a href="JavaScript:void(0);" class="btn" id="submitBtn"><span>保存</span></a></td>
        </tr>
      </tfoot>
    </table>
  </form>
</div>
<script type="text/javascript">
$("#spec_tt").hide();
var i=0;
var tr_model = '<tr class="hover edit">'+
	'<td class="w48 sort"><input type="text" name="s_value[key][sort]" value="0" /></td>'+
	'<td class="w270 name"><input type="text" name="s_value[key][name]" value="" /></td>'+
	'<td class="w270 price"><input type="text" data_type="price" name="s_value[key][price]" value="" /></td>'+
	'<td class="w150 align-center"><a onclick="remove_tr($(this));" href="JavaScript:void(0);">移除</a></td>'+
	'<td></td>'+
'</tr>';
function add_spec()
{
	$("#spec_tt").show();
	$('input[name="goods_store_price"]').attr('readonly','readonly').css('background','#E7E7E7 none');
	$('#tr_model > tr:last').after(tr_model.replace(/key/g,'s_'+i));
	$.getScript("__JS__/admincp.js");
	i++;
}
function remove_tr(o)
{
	o.parents('tr:first').remove();
	var tr_num = $("#tr_model tr").size();
	update_price();
	if(tr_num == 1)
	{
		$('input[name="goods_store_price"]').attr('readonly','').css('background','');
	}	
}
function update_price()
{
	var max = 0.01;
	var min = 10000000;	
	$('input[data_type="price"]').each(function(){
		if($(this).val() != '')
		{
			max = Math.max(max,$(this).val());
			min = Math.min(min,$(this).val());
			$('input[name="goods_store_price"]').val(min);
		}			
		if($(this).val() == '')
		{
			$(this).val($('input[name="goods_store_price"]').val());
		}
	});	
}
$(document).ready(function(){
	$('#submitBtn').click(function(){
		update_price();
	});
});
</script>
<script>
//按钮先执行验证再提交表单
$(function(){$("#submitBtn").click(function(){
    if($("#goods_form").valid()){
     $("#goods_form").submit();
	}
	});
});
//
$(document).ready(function(){
	$('#goods_form').validate({
        errorPlacement: function(error, element){
			error.appendTo(element.parent().parent().prev().find('td:first'));
        },
        success: function(label){
            label.addClass('valid');
        },
        rules : {
            gc_id : {
                required   : true
            },
			goods_name : {
                required   : true
            },
			goods_desc : {
				required : true
            },
			goods_store_price : {
				required   : true,
				number : true
			},
/*			goods_storage:{
				required   : true,
				number : true				
			},*/
			goods_sort : {
				number : true
			},			
			goods_body : {
                required   : true
            }
        },
        messages : {
            gc_id : {
                required   : '请选择分类'
            },
			goods_name : {
                required   : '请输入产品名称'
            },
			goods_desc : {
				required : '输入产品描述'
            },
			goods_store_price : {
				required   : '请输入产品价格',
				number : '产品价格输入错误'
            },	
/*			goods_storage : {
				required   : '请输入产品库存',
				number : '产品库存输入错误'				
			},*/
			goods_sort : {
				number : '排序格式输入错误'
            },					
			goods_body : {
                required   : '请输入产品信息'
            }
        }
    });
	
});
</script>
<script type="text/javascript">
// 模拟网站LOGO上传input type='file'样式
$(function(){
	$("#goods_pic").change(function(){
		$("#txt_goods_pic").val($(this).val());
	});
// 上传图片类型
$('input[class="type-file-file"]').change(function(){
	var filepatd=$(this).val();	
	var extStart=filepatd.lastIndexOf(".");
	var ext=filepatd.substring(extStart,filepatd.lengtd).toUpperCase();		
		/*if(ext!=".PNG"&&ext!=".GIF"&&ext!=".JPG"&&ext!=".JPEG"){
			alert("图片格式错误");
				$(this).attr('value','');
			return false;
		}*/
	});
});
</script>
<include file="Public/footer" />